<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class hotro_model extends CI_Model
{
	public function __construct()
	{
		parent::__construct();
	}
	public function get()
	{
		$query = $this->db->query("SELECT ten, phone FROM hotro WHERE anhien = 1 ORDER BY thutu");
		return $query->result();
	}
	public function select()
	{
		$query = $this->db->query("SELECT * FROM hotro");
		return $query->result();
	}
	public function edit($id)
	{
		$query = $this->db->query("SELECT * FROM hotro WHERE id = ?",array($id));
		return $query->result();
	}
	public function update($id, $ten, $phone, $thutu, $anhien)
	{
		if(is_numeric($id))
		{
			$query = $this->db->query("UPDATE hotro SET ten = ?, phone = ?, thutu = ?, anhien = ? WHERE id = ?", array($ten, $phone, $thutu, $anhien, $id));
			$chk = $this->db->query("SELECT id FROM hotro WHERE ten = ? AND phone = ? AND thutu = ? AND anhien = ? AND id = ?", array($ten, $phone, $thutu, $anhien, $id));
			if($chk->num_rows() > 0) return TRUE;
		} return FALSE;
	}
}